App({
  onLaunch: function (res) {
    console.log('App Launch');
    console.log(res);
    switch (res.scene) {
      case 1044: //带有shareTicket 的小程序消息卡片进入
        this.getShareInfo(res.shareTicket);
        break;
      case 1007: //单人聊天会话中的小程序消息卡片进入 
        console.log('1007：单人聊天会话中的小程序消息卡片进入')
        break;
      case 1008: //群聊会话中的小程序消息卡片进入  
        console.log('1008：群聊会话中的小程序消息卡片进入')
        break;
      default:
        // statements_def
        break;
    };
    // 设置底部tab的右上角红点badge
    wx.setTabBarBadge({
      index: 0,
      text: '666'
    });
    wx.showTabBarRedDot({
      index: 1
    });
  },
  onTabItemTap(item) {
    console.log(item.index)
    console.log(item.pagePath)
    console.log(item.text)
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  },
  globalData: {
    hasLogin: false,
    shareTicket: null
  },
  getShareInfo: function(shareTicketObj){
    wx.getShareInfo({
      shareTicket: shareTicketObj,
      success: res => {
        this.globalData.shareTicket = shareTicketObj;
        console.log(res);
      },
      fail: res => { 
        console.log(res);
      },
      complete: res => {
        console.log(res); 
      },
    })
  },
  onPageNotFound: function(e){
    console.log(e);
  }
})
